package com.lagou.springbootbk.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lagou.springbootbk.dao.ArticleDao;
import com.lagou.springbootbk.model.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {
    @Autowired
    private ArticleDao articleDao;
    @RequestMapping("toIndex")
    public  String index(Model model){
        PageHelper.startPage(1,3);
        Page<Article> result = articleDao.findAll();
        model.addAttribute("result",result);
        return  "index";
    }

    @RequestMapping("list")
    public  String list(Model model,Integer pageNum){
        PageHelper.startPage(pageNum,3);
        Page<Article> result = articleDao.findAll();
        model.addAttribute("result",result);
        return  "index";
    }
}
